get content
Retrieve content from TabNews API by providing a username and slug, enabling integration with MCP TabNews for streamlined data fetching and analysis.
Instructions
get content from tabnews api
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| slug | Yes | The slug to get the content | |
| username | Yes | The username to get the content |
Implementation Reference
- src/tools/status.ts:130-154 (handler)The handler function for the 'get content' tool. It fetches content using the service, formats it as MCP text content with JSON, and handles errors.handler: async (params: GetContentParams): Promise<McpResponse> => { try { const result = await getContent({ username: params.username, slug: params.slug, }); const content: McpTextContent = { type: "text", text: `Content ${params.slug} from ${ params.username }:\n\n${JSON.stringify(result, null, 2)}`, }; return { content: [content], }; } catch (error) { if (error instanceof Error) { throw new Error(`Failed to get content: ${error.message}`); } else { throw new Error("Failed to get content"); } } },
- src/tools/status.ts:126-129 (schema)Zod input schema defining required string parameters: username and slug.parameters: { username: z.string().describe("The username to get the content"), slug: z.string().describe("The slug to get the content"), },
- src/index.ts:45-50 (registration)MCP server registration of the 'get content' tool using server.tool() with its properties.server.tool( getContentTool.name, getContentTool.description, getContentTool.parameters, getContentTool.handler );
- src/services/api.ts:59-69 (helper)Supporting API service function that performs the HTTP fetch to retrieve content from TabNews API.export async function getContent({ username, slug, }: GetContentParams): Promise<TabNewsContentWithBody> { const response = await fetch( `${TABNEWS_API_URL}/contents/${username}/${slug}` ); const data = await response.json(); return data as TabNewsContentWithBody; }